package com 
{
	import data.*;
	import com.GCCity;
	import flash.utils.Dictionary;
	
	/**
	 * ...
	 * @author Jason Won
	 */
	public class GCMap 
	{
		/**
		 * A bit of a hack, the id's of a city are exactly the same as their index in
		 * this array.
		 */
		public var _cities:Dictionary;		
				
		public function GCMap() 
		{
			_cities = new Dictionary();
			if (GCConstants.DEBUG_MODE)
			{
				// DUMMY VALUES 									building id, vector of buildings, number of workers, warehouse inventory, sales inventory
				var picaroonBuildings:Vector.<GCCityBuilding> = new Vector.<GCCityBuilding>();
				picaroonBuildings.push(new GCCityBuilding(GCBuildingData.BUILDING_WAREHOUSE, 0));
				picaroonBuildings.push(new GCCityBuilding(GCBuildingData.BUILDING_FARM, 5));
				var picaroonItems:Vector.<GCItem> = new Vector.<GCItem>();
				picaroonItems.push(new GCItem(0, GCItemData.ITEM_LUMBER, 5, 0, "DUMMY NAME"));
				picaroonItems.push(new GCItem(0, GCItemData.ITEM_COAL, 20, 0, "DUMMY NAME"));
				_cities[GCCityData.CITY_PICAROON] 	 = buildCity(GCCityData.CITY_PICAROON, picaroonBuildings, 5, new GCInventory(picaroonItems, 25, GCBuildingData.WAREHOUSE_CAPACITY), new GCInventory(new Vector.<GCItem>(), 0, GCBuildingData.WAREHOUSE_CAPACITY));
				_cities[GCCityData.CITY_TAFFEREL] 	 = buildCity(GCCityData.CITY_TAFFEREL, 	  null, 0, null, null);
				_cities[GCCityData.CITY_XEBEK] 		 = buildCity(GCCityData.CITY_XEBEK, 	  null, 0, null, null);
				_cities[GCCityData.CITY_MARINO] 	 = buildCity(GCCityData.CITY_MARINO, 	  null, 0, null, null);
				_cities[GCCityData.CITY_ALLEGIO] 	 = buildCity(GCCityData.CITY_ALLEGIO,  	  null, 0, null, null);
				_cities[GCCityData.CITY_ONDA] 		 = buildCity(GCCityData.CITY_ONDA, 		  null, 0, null, null);
				_cities[GCCityData.CITY_HAI_JING] 	 = buildCity(GCCityData.CITY_HAI_JING, 	  null, 0, null, null);
				_cities[GCCityData.CITY_SHANBAN] 	 = buildCity(GCCityData.CITY_SHANBAN, 	  null, 0, null, null);
				_cities[GCCityData.CITY_CHUAN] 		 = buildCity(GCCityData.CITY_CHUAN, 	  null, 0, null, null);
				_cities[GCCityData.CITY_CHUMBUCKET]  = buildCity(GCCityData.CITY_CHUMBUCKET,  null, 0, null, null);
				var dunderfunkBuildings:Vector.<GCCityBuilding> = new Vector.<GCCityBuilding>();
				dunderfunkBuildings.push(new GCCityBuilding(GCBuildingData.BUILDING_WAREHOUSE, 0));
				dunderfunkBuildings.push(new GCCityBuilding(GCBuildingData.BUILDING_SALT_STALL, 5));
				_cities[GCCityData.CITY_DUNDERFUNK]  = buildCity(GCCityData.CITY_DUNDERFUNK,  dunderfunkBuildings, 0, new GCInventory(new Vector.<GCItem>, 0, GCBuildingData.WAREHOUSE_CAPACITY), null);
				_cities[GCCityData.CITY_HORNSWAGGLE] = buildCity(GCCityData.CITY_HORNSWAGGLE, null, 0, null, null);
			}
		}
		
		/** Methods to help build logical items **/
		
		public function constructCity(cid:uint, buildings:Vector.<GCCityBuilding>, numWorkers:uint, warehouse:GCInventory, playerSales:GCInventory):void
		{
			_cities[cid] = new GCCity(cid, buildings, numWorkers, warehouse, playerSales);
		}
		
		// Helper function to create a city
		private function buildCity(id:uint, buildings:Vector.<GCCityBuilding>, numWorkers:uint, warehouse:GCInventory, playerSales:GCInventory): GCCity
		{
			return new GCCity(id, buildings, numWorkers, warehouse, playerSales);
		}
	} 
}
